﻿namespace Microsoft.SharePoint.Client
{
    using System;
    using System.ComponentModel;
    using System.Xml;

    [ScriptType("SP.FieldLinkCreationInformation", ValueObject=true, ServerTypeId="{63fb2c92-8f65-4bbb-a658-b6cd294403f4}")]
    public sealed class FieldLinkCreationInformation : ClientValueObject
    {
        private Microsoft.SharePoint.Client.Field m_field;

        protected override bool InitOnePropertyFromJson(string peekedName, JsonReader reader)
        {
            string str;
            bool flag = false;
            if (((str = peekedName) != null) && (str == "Field"))
            {
                flag = true;
                reader.ReadName();
                this.Field.FromJson(reader);
            }
            return flag;
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override void WriteToXml(XmlWriter writer, SerializationContext serializationContext)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }
            if (serializationContext == null)
            {
                throw new ArgumentNullException("serializationContext");
            }
            writer.WriteStartElement("Property");
            writer.WriteAttributeString("Name", "Field");
            DataConvert.WriteValueToXmlElement(writer, this.Field, serializationContext);
            writer.WriteEndElement();
        }

        [Remote]
        public Microsoft.SharePoint.Client.Field Field
        {
            get
            {
                return this.m_field;
            }
            set
            {
                this.m_field = value;
            }
        }

        [EditorBrowsable(EditorBrowsableState.Never)]
        public override string TypeId
        {
            get
            {
                return "{63fb2c92-8f65-4bbb-a658-b6cd294403f4}";
            }
        }
    }
}

